<template>
	<view>
		<view class="header status_bar" :class="scrrol == true ? 'scrrolHeader' : ''">
			<view class="back iconfont icon-xiangzuo1" @tap="backPage"></view>
			<view class="text" :class="scrrol == true ? 'scrrolHeader' : ''">我的店铺</view>
		</view>	
		<view class="bg_box">
			<image class="bg01" :src="getImgSrc('/static/bg05.png')" mode="widthFix"></image>
			<view class="bg_content">
				<view class="name_box">
					<view class="avatar">
						<image :src="avatar" mode="scaleToFill"></image>
					</view>
					<view class="name_text">
						<view class="name">{{nickname}}</view>
						<view class="realname">
							<view class="real">
								<view class="r iconfont icon-fabucheyuan"></view>
								<view class="t" v-if="is_sm==0" :data-url="'/pages/personalcenter/standing?phone='+phone" @click="gotopage">去实名</view>
								<view class="t" v-if="is_sm==1">已申请</view>
								<view class="t" v-if="is_sm==2">已实名</view>
							</view>
						</view>
					</view>
					<!-- <view class="message" :data-url="'/pages/personalcenter/message'" @click="gotopage">
						<view class="icon iconfont icon-xiaoxi"></view>
						<view class="round"></view>
					</view> -->
				</view>
				
				<view class="menu_box">
					<view class="menu" data-url="" @click="gotopage">
						<view class="num">{{on_car}}</view>
						<view class="text">在售车源</view>
					</view>
					<view class="menu" data-url="" @click="gotopage">
						<view class="num">{{off_car}}</view>
						<view class="text">已售车源</view>
					</view>
					<view class="menu" data-url="" @click="gotopage">
						<view class="num">{{all_num}}</view>
						<view class="text">累计发布</view>
					</view>
				</view>
				<view class="nav">
					<view class="navauto">
						<block v-for="(item, index) in menu" :key="index">
							<view class="menu" :data-index="index" @tap="setNavMenu">
								<view class="text" :class="index == select ? 'menucolor' : ''">{{ item.text }}
								</view>
								<view class="num" v-if="index == 0">{{wholesale}}</view>
								<view class="num" v-if="index == 1">{{dynamics}}</view>
								<view class="num" v-if="index == 2">{{want}}</view>
								<!-- <view class="line" :class="index == select ? 'menucolor02' : ''">
									<image src="../../static/xiao.png" mode="widthFix"></image>
								</view> -->
							</view>
						</block>
					</view>
				</view>
				
				<!-- <scroll-view class="scroll_box" scroll-y="true" @scrolltolower="lower"> -->
					<view v-if="type != 1">
						<block v-for="(item,index) in info">
							<view class="goods_list" :data-url="url+item.id" @click="gotopage">
								<view class="goods_img">
									<image :src="item.logo" mode="scaleToFill" v-if="item.logo"></image>
								</view>
								<view class="goods_text">
									<view class="title" v-if="type != 1"> {{item.content}}</view>
									<view class="title_2" v-if="type == 1"> {{item.content}}</view>
									<view class="text">{{item.subtitle}}</view>
									<view class="money_box">
										<view class="money">{{item.market_price}}</view>
										<view class="rule" v-if="type == 0">{{item.time}}</view>
									</view>
									<view class="other" v-if="type == 1">
										<!-- <view class="i iconfont icon-bianji"></view> -->
										<view class="rule">{{item.time}}</view>
										<view class="off_but" @click="off_car(index,3)" v-if="item.status == 1">下架</view>
										<view class="off_but" @click="off_car(index,1)" v-if="item.status == 3">上架</view>
										<view class="off_but" @click="del_car(item.id)">删除</view>
									</view>
									<view class="other" v-if="type == 2">
										<view class="rule">{{item.time}}</view>
										<view class="off_but" @click="del_want(item.id)">删除</view>
									</view>
								</view>
							</view>
						</block>
					</view>
					
					<view v-if="type == 1" class="c_circle">
						<block v-for="(item,index) in info">
							<view class="circle_list">
								<view class="circle_value">
									<!-- <view class="type">置顶</view> -->
									<view class="value" v-bind:selectable="true" @longpress="onLongPress(item.content)">{{item.content}}</view>
								</view>
								<view class="circle_picture" v-if="item.thumb && item.thumb.length > 1">
									<block v-for="(item_0,index_0) in item.thumb" :key="index">
										<view class="picture" v-if="index_0 < 2">
											<image class="image" :src="item_0" mode="aspectFill" @tap.stop="openPreviewImage(item.thumb,index_0)"></image>
										</view>
										<view class="picture_2" v-if="index_0 == 2 && item.thumb.length > 3">
											<image class="image" :src="item_0" mode="aspectFill" @tap.stop="openPreviewImage(item.thumb,index_0)"></image>
											<text class="count">+{{ item.thumb.length - 3 }}</text>
										</view>	
										<view class="picture" v-if="index_0 == 2 && item.thumb.length <= 3">
											<image class="image" :src="item_0" mode="aspectFill" @tap.stop="openPreviewImage(item.thumb,index_0)"></image>
										</view>	
									</block>
								</view>
								<view class="circle_picture" v-if="item.thumb && item.thumb.length < 2" :style="{ width: '30% !important'}">
									<block v-for="(item_0,index_0) in item.thumb" :key="index">
										<view class="picture">
											<image class="image" :src="item_0" mode="aspectFill" @tap.stop="openPreviewImage(item.thumb,index_0)"></image>
										</view>
									</block>
								</view>
								<view class="circle_other">
									<view class="time">{{item.time}}</view>
									<view class="icon_box">
										<view class="icon">
											<view class="off_but" @click="off_circle(index,3)" v-if="item.status == 1">下架</view>
											<view class="off_but" @click="off_circle(index,1)" v-if="item.status == 3">上架</view>
										</view>
										<view class="icon">
											<view class="off_but" @click="del_car(item.id)">删除</view>
										</view>
									</view>
								</view>
							</view>
						</block>
					</view>
					<view style="text-align: center;padding-top: 5vw;margin-bottom: 5vw;" v-if="empty">
						<u-empty text="暂无数据" mode="list">没有更多了</u-empty>
					</view>	
				<!-- </scroll-view> -->
				
			</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				page:1,
				scrrol:false,
				info:'',
				select:0,
				menu: [
					{
						text: '批发车源'
					},
					{
						text: '朋友圈车源'
					},
					{
						text: '我的求购'
					},
				],
				type:0,
				avatar:'',
				nickname:'',
				is_store:'',
				is_sm:0,
				wholesale:0,
				dynamics:0,
				want:0,
				url:'/pages/goods/goods?id=',
				off_car:0,
				on_car:0,
				all_num:0,
				empty:0,
			}
		},
		onLoad(e) {
			if(e.index){
				this.select = e.index;	
				this.type = e.index;
			}
			this.loadData();
			this.loadList();
		},
		methods: {
			setNavMenu(e) {
				let that = this;
				let index = e.currentTarget.dataset.index;
				that.select = index;
				that.type = index;
				that.page = 1;
				if (index == 0){
					that.url = '/pages/goods/goods?id=';
				}
				if (index == 1){
					that.url = '';
				}
				if (index == 2){
					that.url = 'pages/service/publish02_edit?id=';
				}
				that.loadList();
			},
			setRule(e){
				let that = this;
				let index = e.currentTarget.dataset.index;
				that.flowList[index].tick = !that.flowList[index].tick
			},
			loadData() {
				let that = this;
				that.Net._get('auth/team/shop', {}, res => {
					if (res.code == 1) {
						that.avatar = res.data.avatar;
						that.nickname = res.data.nickname;
						that.is_store = res.data.is_store;
						that.is_sm = res.data.is_sm;
						that.wholesale = res.data.wholesale;
						that.dynamics = res.data.dynamics;
						that.want = res.data.want;
						that.on_car = res.data.on_car;
						that.off_car = res.data.off_car;
						that.all_num = res.data.all_num;
					}
				});
			},
			loadList(){
				let that = this;
				that.Net._get('auth/team/my_posts', {page:that.page,type:that.type}, res => {
					if (res.code == 1) {
						that.info = res.data;
						if (that.info.length == 0){
							that.empty=1;
						}
					}
				});
			},
			off_circle(idx,status){
				let that = this;
				let cid = that.info[idx].id;
				that.Net._post('auth/team/off_circle', {id:cid,status:status}, res => {
					if (res.code == 1) {
						that.Msg.Success('操作成功', res => {
							that.page == 1;
							that.loadList();
						});
					}
				});
			},
			del_car(id){
				let that = this;
				uni.showModal({
				    title: '确认提示',
				    content: '是否确认删除',
				    success:(res) => {
				        if (res.cancel){
				            return false;
				        }
						uni.showLoading({
							title: '删除中'
						});
						that.Net._post('auth/team/del_circle', {id:id}, res => {
							if (res.code == 1) {
								that.Msg.Success('删除成功', res => {
									uni.hideLoading();
									that.page == 1;
									that.loadList();
									this.loadData();
								});
							}
						});
				    }
				});
			},
			del_want(id){
				let that = this;
				uni.showModal({
				    title: '确认提示',
				    content: '是否确认删除',
				    success:(res) => {
				        if (res.cancel){
				            return false;
				        }
						uni.showLoading({
							title: '删除中'
						});
						that.Net._post('auth/member/want_del_hand', {id:id}, res => {
							if (res.code == 1) {
								that.Msg.Success('删除成功', res => {
									uni.hideLoading();
									that.page == 1;
									that.loadList();
									this.loadData();
								});
							}
						});
				    }
				});
			},
			openPreviewImage(e,index) {
				let that = this;
				let img_ = e;
				uni.previewImage({
					current: index, // 当前显示图片索引
					urls: img_,
					loop:true
				});
			},
			backPage() {
				uni.navigateBack({});
			},
			gotopage(e) {
				let url = e.currentTarget.dataset.url;
				uni.navigateTo({
					url: url
				});
			},

		},
		onPageScroll: function(Object) {
			//console.log(Object.scrollTop); //实时获取到滚动的值
			if (Object.scrollTop > 28) {
				this.scrrol = true;
				/* #ifdef APP-PLUS */
				/* #endif */
			} else if (Object.scrollTop < 28) {
				this.scrrol = false;
				/* #ifdef APP-PLUS */
				/* #endif */
			}
		},
		onReachBottom() {
			var that = this;
			that.page++;
			that.Net._get('auth/team/my_posts', {page:that.page,type:that.type}, res => {
				if (res.code == 1) {
					if (res.data == '') {
						uni.showToast({
							title: '没有更多了',
							duration: 2000,
							icon: 'none'
						});
						that.empty=1;
					} else {
						that.info = that.info.concat(res.data); //将数据拼接在一起
					}
				} else if (res.code == 0) {
					that.Msg.Success(res.msg, res => {});
				}
			});
		},
	}
</script>

<style>
	.off_but{
		padding: 0 2vw 0 2vw;
		border-radius: 5vw;
		// background-color: #FF9800;
		display: flex;
		align-items: center;
		margin-left: 1vw;
		border:1px solid #777777;
	}
	.other{
		flex: 1;
		display: flex;
		float: right;
	}
	
	.other:nth-child(1){
		border-right: 1px solid #F3F3F3;
	}
	
	.other .i{
		font-size: 5vw;
		color: #B8B8B8;
		margin-right: 1vw;
	}
	
	.other .t{
		font-size: 3.8vw;
		color: #666666;
	}
	.header{
		background-color: transparent !important;
		height: 18vw !important;
	}
	
	.header .text{
		background-color: transparent !important;
		color: #333 !important;
	}
	
	.header .back{
		color: #333 !important;
	}
	
	.scrrolHeader{
		background-color: #F9E9E3 !important;
	}
	
	.bg_box{
		width: 100%;
		position: relative;
	}
	
	.bg_box .bg01{
		width: 100%;
	}
	
	.bg_box .bg_content{
		width: 92%;
		position: absolute;
		left: calc(50% - 46%);
		top: calc(13.5vw + var(--status-bar-height));
		z-index: 98;
	}
	
	.name_box {
		width: 100%;
		margin-top: 4%;
		display: flex;
		align-items: center;
	}
	
	.name_box .avatar {
		width: 18vw;
		height: 18vw;
		margin-right: 4%;
		margin-left: 4%;
		background-color: #fff;
		border-radius: 50%;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	
	.name_box .avatar image {
		width: 90%;
		height: 90%;
		border-radius: 50%;
	}
	
	.name_box .name_text {
		flex: 1;
	}
	
	.name_box .name_text .name {
		font-size: 5vw;
		color: #333;
		font-weight: bold;
	}
	
	.name_box .name_text .realname {
		margin-top: 2vw;
		display: flex;
	}
	
	.name_box .name_text .realname .real {
		height: 7vw;
		padding: 0 2vw 0 3vw;
		border-radius: 7vw;
		background-color: #FC5D20;
		display: flex;
		align-items: center;
	
	}
	
	.name_box .name_text .realname .real .t {
		font-size: 3vw;
		color: #fff;
		
	}
	
	.name_box .name_text .realname .real .r {
		font-size: 2.7vw;
		color: #fff;
		margin-right: 1vw;
	}
	
	.name_box .message {
		position: relative;
		margin-right: 4%;
	}
	
	.name_box .message .icon {
		font-size: 8vw;
		color: #333;
	}
	
	.name_box .message .round {
		height: 3vw;
		width: 3vw;
		box-sizing: border-box;
		border-radius: 50%;
		text-align: center;
		position: absolute;
		right: 0vw;
		top: 0;
		background-color: #FC5D20;
		color: #fff;
	}
	
	.menu_box {
		width: 100%;
		margin: 0 auto;
		display: flex;
		padding: 6vw 0;
		border-radius: 2vw;
		margin-top: 4%;
		background-color: #fff;
		border-radius: 3vw;
	}
	
	.menu_box .menu {
		flex: 1;
	}
	
	.menu_box .menu .num {
		font-size: 5vw;
		font-weight: bold;
		color: #1d1f24;
		text-align: center;
	}
	
	.menu_box .menu .text {
		font-size: 3.2vw;
		color: #7C8191;
		text-align: center;
		margin-top: 1vw;
	}
	
	.scroll_box {
		width: 100%;
		height: 63vh;
		margin-top: 4%;
	}
	
	.goods_list {
		width: 100%;
		display: flex;
		margin-top: 4%;
	}
	
	.goods_list .goods_img {
		width: 32vw;
		height: 25vw;
		margin-right: 3vw;
	}
	
	.goods_list .goods_img image {
		width: 100%;
		height: 100%;
		border-radius: 2vw;
	}
	
	.goods_list .goods_text {
		flex: 1;
	}
	
	.goods_list .goods_text .title {
		font-size: 4vw;
		color: #333;
		font-weight: bold;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
		overflow: hidden;
	}
	
	.goods_list .goods_text .text {
		font-size: 3.5vw;
		color: #999999;
		margin-top: 2vw;
	}
	
	.goods_list .goods_text .money_box {
		margin-top: 1vw;
		display: flex;
		align-items: center;
	}
	
	.goods_list .goods_text .money_box .money {
		font-size: 4.5vw;
		font-weight: bold;
		color: #FF6826;
		flex: 1;
	}
	
	.goods_list .goods_text .money_box .rule {
		font-size: 3.5vw;
		color: #999999;
		flex: 1;
		text-align: right;
	}
	
	.nav {
		width: 100%;
		height: 13.5vw;
		overflow: hidden;
		overflow-x: auto;
		box-sizing: border-box;
	}
	
	.nav .navauto {
		width: 100%;
		display: flex;
		/* margin-left: 4%; */
		min-width: 100%;
	}
	
	.nav .navauto .menu {
		width: 33.3333%;
		position: relative;
	}
	
	.nav .navauto .menu .text {
		font-size: 4.2vw;
		color: #666666;
		text-align: center;
		line-height: 13.5vw;
	}
	
	.nav .navauto .menu .line {
		width: 20%;
		border-radius: 3vw;
		position: absolute;
		left: calc(50% - 10%);
		bottom: 1vw;
		display: none;
	}
	
	.nav .navauto .menu .line image{
		width: 100%;
	}
	
	.nav .navauto .menu .num {
		text-align: center;
		margin-top: -4vw;
	}
	
	.menucolor {
		color: #091624 !important;
		font-weight: bold;
		font-size: 4.4vw !important;
	}
	
	.menucolor02 {
		display: block !important;
	}
	
	.menucolor03 {
		background-color: #FF9822 !important;
	}
	
	.goods_list .goods_text .title_2 {
		font-size: 4vw;
		color: #333;
		font-weight: bold;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 3;
		overflow: hidden;
	}
	.circle_list {
		width: 100%;
		background-color: #fff;
		padding: 2%;
		border-bottom: 1px solid #F7F8FC;
		border-radius: 3vw;
		margin-top: 2vw;
	}
	
	.circle_list .circle_box {
		width: 100%;
		display: flex;
		align-items: center;
	}
	
	.circle_list .circle_box .circle_img {
		width: 12vw;
		height: 12vw;
		margin-right: 2vw;
	}
	
	.circle_list .circle_box .circle_img image {
		width: 100%;
		height: 100%;
		border-radius: 2vw;
	}
	
	.circle_list .circle_box .circle_text {
		flex: 1;
	}
	
	.circle_list .circle_box .circle_text .name {
		font-size: 4vw;
		color: #333;
		font-weight: bold;
	}
	
	.circle_list .circle_box .circle_text .text {
		font-size: 3.5vw;
		color: #999999;
		margin-top: 1vw;
	}
	
	.circle_list .circle_box .circle_text .text span {
		color: #FF6A23;
	}
	
	.circle_list .circle_box .orientation {
		font-size: 3.6vw;
		color: #999999;
	}
	
	.circle_list .circle_value {
		margin-top: 2vw;
		display: flex;
	}
	
	.circle_list .circle_value .type {
		width: 10vw;
		height: 5vw;
		font-size: 3vw;
		color: #fff;
		background-color: #FF5227;
		margin-right: 1vw;
		border-radius: 1vw;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	
	.circle_list .circle_value .value {
		font-size: 3.7vw;
		color: #333;
		font-weight: bold;
	}
	
	.circle_list .circle_picture {
		width: 100%;
		margin-top: 2vw;
		display: flex;
	
	}
	
	.circle_list .circle_picture .picture {
		flex: 1;
		height: 30vw;
		margin-left: 1vw;
	}
	
	.circle_list .circle_picture .picture:nth-child(1) {
		margin-left: 0;
	}
	
	.circle_list .circle_picture .picture image {
		width: 100%;
		height: 100%;
		border-radius: 2vw;
	}
	
	.circle_list .circle_picture .picture_2 {
		flex: 1;
		height: 30vw;
		margin-left: 1vw;
		background-color: rgba(0, 0, 0, 0.5);
	}
	
	.circle_list .circle_picture .picture_2:nth-child(1) {
		margin-left: 0;
	}
	
	.circle_list .circle_picture .picture_2 image {
		width: 100%;
		height: 100%;
		border-radius: 2vw;
		opacity: 0.5;
	}
	
	.circle_other {
		width: 100%;
		/* margin-bottom: 3vw; */
		display: flex;
		align-items: center;
		margin-top: 1vw;
	}
	
	.circle_other .time {
		font-size: 3.8vw;
		color: #999;
	}
	
	.circle_other .icon_box {
		flex: 1;
		display: flex;
		align-items: center;
		justify-content: flex-end
	}
	
	.circle_other .icon_box .icon {
		width: 16vw;
		display: flex;
		align-items: center;
	}
	
	.circle_other .icon_box .icon .i {
		font-size: 4vw;
		color: #333;
		margin-right: 1vw;
	}
	
	.circle_other .icon_box .icon .t {
		font-size: 3.6vw;
		color: #333;
		font-weight: bold;
	}
	
	.circle_other .icon_box .icon .c {
		font-size: 3.6vw;
		color: #FF9800;
		font-weight: bold;
	}
	.nav .navauto .menu .num {
	    text-align: center;
	    margin-top: -4vw;
	}
	
	.c_circle{
		margin-top: 1%;
		border-radius: 3vw;
	}
	
	.count {
		position: relative;
		top: -60%; /* Adjust this value based on the size of your images */
		left: 50%; /* Adjust this value based on the size of your images */
		color: white;
		font-size: 20px;
	}
</style>
